package com.niit.controller;

import com.niit.model.Classes;
import com.niit.service.ClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;

@Api(value = "学生模块",tags = {"学生模块"})
@RestController
public class ClassController {
    @Autowired
    public void setClassService(ClassService classService) {
        this.classService = classService;
    }
    private ClassService classService;
    @ApiOperation("根据ID查询班级")
    @GetMapping("/class/{id}")
    public List<Classes> getClassById(@PathVariable("id")Long id){
        return classService.selectClassId(id);
    }

    @ApiOperation("根据ID退出班级")
    @DeleteMapping("/class/{id1}/{id2}")
    public String deleteClassById(@PathVariable("id1")Long id1,@PathVariable("id2")Long id2){
        return  classService.deleteClassById(id1,id2)>0?"success":"fail";
    }

    @GetMapping("/studentclass/{id1}/{id2}")
    public int addStudentClassById(@PathVariable("id1")Long id1, @PathVariable("id2")Long id2){
        return classService.addStudentClassById(id1,id2,new Date());
    }
}
